feat(auth): user-scoped tenant discovery for tenant switchers (ADR-0011) - #21
Merged
swimmesberger merged 1 commit intoAug 10, 2026
Merged
Conversation
A tenant stack (and a granted management stack) can now ask which sibling
tenants the proven visiting user may reach, powering an in-product tenant
switcher with Watchtower as the identity provider.
- GET /api/app/tenants/accessible — siblings of the caller's own template
the user may enter (slug + domain, caller marked current when present).
- GET /api/mgmt/templates/{id}/tenants/accessible — the same user-filtered
view for a granted management stack; the unfiltered list is unchanged.
- Proof of user is the forwarded X-Watchtower-Jwt assertion: a new
audience-validating AuthTokenSigner overload requires aud to match one of
the CALLING stack's own route domains (case-insensitive via a custom
AudienceValidator; empty set fails closed), then the user row is reloaded
so disabled accounts are refused within the token window. One uniform 401
for every assertion failure.
- RouteAccessPolicy.AccessibleRouteIdsAsync: bulk per-template access
evaluation (Public/Authenticated pass, Restricted via one grants query,
unknown modes fail closed).
- Slug 'accessible' reserved at provisioning (route-literal shadowing).
- Both endpoints 404 when central auth is off, per the UserInfo precedent.
- ADR-0011 records the scoped amendment of ADR-0008's self-only invariant;
both public API docs updated; ADR-0008/0009 gained pointers.
- 31 new tests incl. wrong-audience, alg-confusion-with-correct-aud,
routeless-caller, fail-closed unknown mode, and uniform-401 equality.
swimmesberger
force-pushed
the
wt/tenant-switcher
branch
from
August 10, 2026 13:16
23e19fd to
3c05312
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #19 — merge that first, then this (base is its branch so the diff stays scoped).
What
Two endpoints answering which sibling tenants may the proven visiting user reach, powering an in-product tenant switcher with Watchtower as the identity provider for the apps it proxies:
GET /api/app/tenants/accessible— for the product UI itself (a tenant stack): accessible siblings of its own template asslug+domain, the caller markedcurrentwhen it appears.GET /api/mgmt/templates/{id}/tenants/accessible— the same user-filtered view for a granted management stack (its unfiltered operations list is unchanged).How the user is proven
The caller forwards the visitor's
X-Watchtower-Jwt(already delivered on every proxied request) alongside its ownwtapp_token. A new audience-validatingAuthTokenSigneroverload requires the JWT'saudto match one of the calling stack's own route domains (customAudienceValidator, case-insensitive; empty set fails closed) — so an app can only ask about users actively visiting it, and a JWT leaked to another app is inert. The user row is then re-read, refusing disabled accounts within the 5-minute token window. Every assertion failure yields one uniform401.Access per sibling follows the central-auth policy on its primary route —
Public/Authenticatedpass,Restrictedneeds aRouteAccessGrant, unknown modes fail closed — via a new bulkRouteAccessPolicy.AccessibleRouteIdsAsync(one grants query per template).Reviewer notes
accessibleis now reserved at provisioning — it would collide with the literal route segment.404when central auth is off (UserInfo precedent).currentmay be absent — documented.Verification
dotnet buildRelease 0 warnings · 355 tests green · norpc-schema.jsondrift ·npm run buildclean.